package hellfire.game.weapons;

import java.util.Vector;

import hellfire.game.Algorithms;
import hellfire.game.Chicken;
import hellfire.game.ChickenDebris;
import hellfire.game.Game;
import hellfire.platform.graphics.AbstractRenderer;
import hellfire.platform.graphics.BallRenderer;
import hellfire.platform.graphics.BombRenderer;
import hellfire.system.graphics.GLRelVec2;
import hellfire.system.graphics.GLVec2;

public class Bomb extends AbstractWeapon
{
	
	private GLVec2 pos;
	private Game game;
	private float timeLeft = 240;
	private static GLVec2 dim = new GLVec2(0.05f, 0.05f);
	private static float radius = 0.5f;
	private BombRenderer renderer;
	
	public Bomb(GLVec2 pos, Game game)
	{
		this.pos = pos;
		this.game = game;
		renderer = new BombRenderer();
	}
	
	
	@Override
	public void gameFrame()
	{
		timeLeft--;
		if(timeLeft == 0)
			Explode();
	}
	
	public GLVec2 getRenderPos()
	{
		return new GLRelVec2(pos);
	}
	
	public void Explode()
	{
		//game.getChickenDebris().add(new ChickenDebris(this));
		
		Vector<Object> chickens = game.getObjectsAtPoint(getRenderPos(), Chicken.class, radius);
		for(Object c : chickens)
		{
			Chicken chicken = (Chicken) c;
			chicken.Explode();
		}
		game.getWeapons().remove(this);
		
	}
	
	public GLVec2 getPos()
	{
		return this.pos;
	}
	
	public static GLVec2 getDim()
	{
		return dim;
	}

	@Override
	public AbstractRenderer getRenderer() 
	{
		return this.renderer;
	}

}
